package com.apexsoft.test.sample.ams.producer;

import com.apexsoft.aas.service.annotations.ABusiness;
import com.apexsoft.aas.service.annotations.AService;
import com.apexsoft.aas.service.model.*;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: initializr
 * @Description:
 * @Date: Created in 2019-10-23 13:43
 * @MODIFIED BY:
 */
@ABusiness(namespace = "test",pkg = "download")
public class ADownloadProducerDemo {

    @AService(name="service")
    public ADownloadResponse service1(ADownloadRequest req) throws FileNotFoundException {
        String fileName = (String) req.getParams().get("filename");

        File file = new File(fileName);
        ADownloadResponse resp = new ADownloadResponse();
        resp.setInputStream(new FileInputStream(file));
        resp.setFileInfo(new DownloadFileInfo(){{
            setCode(1);
            setFileName("test.md");
        }});

        return resp;
    }


}
